package com.logistics.log.entity.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import com.logistics.log.entity.model.LogSave;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 
 * </p>
 *
 * @author zhiyu.fan
 * @since 2024-05-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_log")
public class Log implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String businessName;

    private String method;

    private String methodName;

    private String context;

    private String status;

    private String type;

    private String requestAddress;

    private String requestMethod;

    private String parameter;

    private String createOrgCode;

    private String createDepCode;

    private String creator;

    private Date createTime;

    private String updater;

    private Date updateTime;

    public Log(){

    }

    public Log(LogSave logSave){
        this.businessName = logSave.getBusinessName();
        this.method = logSave.getMethod();
        this.methodName = logSave.getMethodName();
        this.context = logSave.getContext();
        this.status = logSave.getStatus();
        this.type = logSave.getType();
        this.requestAddress = logSave.getRequestAddress();
        this.requestMethod = logSave.getRequestMethod();
        this.parameter = logSave.getParameter();
        this.createOrgCode = logSave.getCreateOrgCode();
        this.createDepCode = logSave.getCreateDepCode();
        this.creator = logSave.getCreator();
        this.createTime = DateUtils.stringToDateFormat(logSave.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = logSave.getUpdater();
        this.updateTime = DateUtils.stringToDateFormat(logSave.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static Log build(LogSave logSave){
        return new Log(logSave);
    }
}
